package cn.iocoder.yudao.framework.common.pojo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Max-u-19
 */
@Schema(description = "分页结果")
@Data
public class MyPageResult<T> implements Serializable {


        @Schema(description = "数据", requiredMode = Schema.RequiredMode.REQUIRED)
        private List<T> list;

        @Schema(description = "总量", requiredMode = Schema.RequiredMode.REQUIRED)
        private Long total;

        @Schema(description = "本页合计", requiredMode = Schema.RequiredMode.REQUIRED)
        private BigDecimal totalAmount;

        public MyPageResult() {
        }

        public MyPageResult(List<T> list, Long total, BigDecimal totalAmount) {
            this.list = list;
            this.total = total;
            this.totalAmount = totalAmount;
        }

        public MyPageResult(Long total) {
            this.list = new ArrayList<>();
            this.total = total;
            this.totalAmount = BigDecimal.ZERO;
        }

    public static <T> MyPageResult<T> empty() {
        return new MyPageResult<>(0L);
    }

    public static <T> MyPageResult<T> empty(Long total) {
        return new MyPageResult<>(total);
    }

}
